from appium import webdriver


def init_driver():
    desired_caps = {}
    # 设备信息
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '5.1.1'
    desired_caps['deviceName'] = '127.0.0.1:5555'
    # desired_caps['deviceName'] = '127.0.0.1:4723' #也OK
    # 指定要操作某app的某UI
    desired_caps['appPackage'] = 'com.jym.mall'  # 交易猫app
    desired_caps['appActivity'] = '.home.HomeActivity'  # 主UI

    # 指定Appium服务器的ip和端口
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    return driver